/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fri.entiry;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author NguyenDongUIT
 */
@Entity
@Table(name = "fr_user")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "FrUser.findAll", query = "SELECT f FROM FrUser f"),
    @NamedQuery(name = "FrUser.findByUserId", query = "SELECT f FROM FrUser f WHERE f.userId = :userId"),
    @NamedQuery(name = "FrUser.findByEmail", query = "SELECT f FROM FrUser f WHERE f.email = :email"),
    @NamedQuery(name = "FrUser.findByFullName", query = "SELECT f FROM FrUser f WHERE f.fullName = :fullName"),
    @NamedQuery(name = "FrUser.findByUserCode", query = "SELECT f FROM FrUser f WHERE f.userCode = :userCode"),
    @NamedQuery(name = "FrUser.findByAvatar", query = "SELECT f FROM FrUser f WHERE f.avatar = :avatar"),
    @NamedQuery(name = "FrUser.findByPassword", query = "SELECT f FROM FrUser f WHERE f.password = :password"),
    @NamedQuery(name = "FrUser.findByDateCreated", query = "SELECT f FROM FrUser f WHERE f.dateCreated = :dateCreated"),
    @NamedQuery(name = "FrUser.findByLastEffect", query = "SELECT f FROM FrUser f WHERE f.lastEffect = :lastEffect")})
public class FrUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 36)
    @Column(name = "UserId")
    private String userId;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 128)
    @Column(name = "Email")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 128)
    @Column(name = "FullName")
    private String fullName;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 8)
    @Column(name = "UserCode")
    private String userCode;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "Avatar")
    private String avatar;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "Password")
    private String password;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DateCreated")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateCreated;
    @Basic(optional = false)
    @NotNull
    @Column(name = "LastEffect")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastEffect;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "frUser")
    private List<FrUserinrole> frUserinroleList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userId")
    private List<FrHistory> frHistoryList;
    @OneToMany(mappedBy = "toUserId")
    private List<FrPaymentcode> frPaymentcodeList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fromUserId")
    private List<FrPaymentcode> frPaymentcodeList1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userId")
    private List<FrUsermoney> frUsermoneyList;

    public FrUser() {
    }

    public FrUser(String userId) {
        this.userId = userId;
    }

    public FrUser(String userId, String email, String fullName, String userCode, String avatar, String password, Date dateCreated, Date lastEffect) {
        this.userId = userId;
        this.email = email;
        this.fullName = fullName;
        this.userCode = userCode;
        this.avatar = avatar;
        this.password = password;
        this.dateCreated = dateCreated;
        this.lastEffect = lastEffect;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getUserCode() {
        return userCode;
    }

    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getDateCreated() {
        return dateCreated;
    }

    public void setDateCreated(Date dateCreated) {
        this.dateCreated = dateCreated;
    }

    public Date getLastEffect() {
        return lastEffect;
    }

    public void setLastEffect(Date lastEffect) {
        this.lastEffect = lastEffect;
    }

    @XmlTransient
    public List<FrUserinrole> getFrUserinroleList() {
        return frUserinroleList;
    }

    public void setFrUserinroleList(List<FrUserinrole> frUserinroleList) {
        this.frUserinroleList = frUserinroleList;
    }

    @XmlTransient
    public List<FrHistory> getFrHistoryList() {
        return frHistoryList;
    }

    public void setFrHistoryList(List<FrHistory> frHistoryList) {
        this.frHistoryList = frHistoryList;
    }

    @XmlTransient
    public List<FrPaymentcode> getFrPaymentcodeList() {
        return frPaymentcodeList;
    }

    public void setFrPaymentcodeList(List<FrPaymentcode> frPaymentcodeList) {
        this.frPaymentcodeList = frPaymentcodeList;
    }

    @XmlTransient
    public List<FrPaymentcode> getFrPaymentcodeList1() {
        return frPaymentcodeList1;
    }

    public void setFrPaymentcodeList1(List<FrPaymentcode> frPaymentcodeList1) {
        this.frPaymentcodeList1 = frPaymentcodeList1;
    }

    @XmlTransient
    public List<FrUsermoney> getFrUsermoneyList() {
        return frUsermoneyList;
    }

    public void setFrUsermoneyList(List<FrUsermoney> frUsermoneyList) {
        this.frUsermoneyList = frUsermoneyList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userId != null ? userId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FrUser)) {
            return false;
        }
        FrUser other = (FrUser) object;
        if ((this.userId == null && other.userId != null) || (this.userId != null && !this.userId.equals(other.userId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fri.entiry.FrUser[ userId=" + userId + " ]";
    }
    
}
